<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            background-color: rgb(159, 161, 163);
            width: 100px;
            height: 100px;
            position: absolute;
            left: 0;
            top: 50px;
        }
    </style>
</head>

<body>
    <button id="btn">运动吧！小托比</button>
    <div id="diamond"><img src="../easy-js/img/戴口罩.gif" alt=""></div>
    <script>
        ;
        var btn = document.getElementById("btn");
        var dia = document.getElementById("diamond")
        var count = 0;
        btn.onclick = function () {
            time = setInterval(function () {
                count += 10;
                if (count % 800 == 0) {
                    count = 0;
                    clearInterval(time);
                } dia.style.left = count + 'px';
            }, 10)
        };


    </script>
</body>

</html>